<?php
/**
 * Services Preprocessor
 * 服务预处理程序
 */
#调式开关
if($Config_Services['Debug']==FALSE)
    error_reporting(0);         //不显示错误异常信息
else
    error_reporting(E_ALL);     //显示所有错误异常信息 error_reporting(E_ALL&~E_NOTICE);

#过滤非法调用
$IsValid='FALSE';
$Url=parse_url($_SERVER['HTTP_REFERER']);
$Host=$Url['host'];
for ($i=0;$i<count($Config_Services['ValidDomain']);$i++)
{
    if($Config_Services['ValidDomain'][$i]==$Host) $IsValid='TRUE';
}
if($IsValid=='FALSE')
{
    error_reporting(E_ALL);
    if($Config_Services['Debug']==FALSE)
        header('HTTP/1.1 403 Forbidden');
    else
        header('HTTP/1.1 403 Is not valid URL');
    exit();
}

#验证口令
$Password=urlArgs('_servicePassword_');
if($Password==NULL) $Password=formArgs('_servicePassword_');
if($Config_Services['Password']!=$Password)
{
    error_reporting(E_ALL);
    if($Config_Services['Debug']==FALSE)
        header('HTTP/1.1 403 Forbidden');
    else
        header('HTTP/1.1 403 Wrong password');
    exit();
}
?>